FROM ccr.ccs.tencentyun.com/scentrobe/go:0.0.1 as builder

LABEL stage=gobuilder

WORKDIR /build

COPY . .
COPY service/backend/rmq/etc /app/etc
RUN go build -ldflags="-s -w" -o /app/backend service/backend/rmq/backend.go


FROM ccr.ccs.tencentyun.com/scentrobe/alpine:base

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV TZ Asia/Shanghai

WORKDIR /app
COPY --from=builder /app/backend /app/backend
COPY --from=builder /app/etc /app/etc

RUN chown -R app:app ./
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
USER app

CMD ["./backend", "-f", "etc/backend.prod.yaml"]
